package com.hspedu.newData.dmsxl.动态规划.背包问题;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-20 
 * @Version: 1.0
 */

public class LC494目标和 {

    // 回溯
    int sum = 0;
    int count = 0;
    public int findTargetSumWays1(int[] nums, int target) {
        backtrack(nums,target,0);
        return count;
    }


    public void backtrack(int[] nums,int startIndex,int target){
        if (startIndex == nums.length){
            if(sum == target){
                count++;
            }
        }else{
            sum += nums[startIndex];
            backtrack(nums,startIndex+1,target);
            sum -= 2*nums[startIndex];
            backtrack(nums,startIndex+1,target);
            sum += nums[startIndex];
        }
    }

    // 动态规划
    public int findTargetSumWays(int[] nums, int target) {


        return 1;
    }
}
